package com.itheima_0517_02.domain;

import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student stu = new Student("张三",16);
        Student stu1 = new Student("李四",17);
        Student stu2 = new Student("王五",19);
        list.add(stu);
        list.add(stu1);
        list.add(stu2);
        ArrayList<Student> newList = getList(list);
        for (int i = 0; i < newList.size(); i++) {
            Student s = newList.get(i);
            System.out.println(s.getUsername()+"...."+s.getAge());
        }
    }
    public static ArrayList<Student> getList(ArrayList<Student> list){
        ArrayList<Student> newList = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            if(stu.getAge() < 18){
                newList.add(stu);
            }
        }
        return newList;
    }
}
